package reduce.fz.com.reduce.custom;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import reduce.fz.com.reduce.R;

/**
 * Created by qingshengzheng on 15/7/21.
 */
public class CardOperBtn extends LinearLayout {
    //@drawable/iconfont_zan   赞，私聊，评论

    private LayoutInflater layoutInflater;
    private ImageView mImage;
    private TextView mTitle;

    public CardOperBtn(Context context) {
        super(context);

    }

    public CardOperBtn(Context context, AttributeSet attrs) {
        super(context, attrs);
        layoutInflater = LayoutInflater.from(context);
        View view = layoutInflater.inflate(R.layout.card_oper_btn, this);
        mImage = (ImageView) view.findViewById(R.id.oper_image);
        mTitle = (TextView) view.findViewById(R.id.oper_title);
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.cardOper);
        String title = a.getString(R.styleable.cardOper_imagetitle);
        Drawable imageDraw = a.getDrawable(R.styleable.cardOper_imagesrc);
        this.setImageAndTitle(imageDraw, title);


    }

    public void setImageAndTitle(Drawable imageDraw, String title) {
        mImage.setImageDrawable(imageDraw);
        mTitle.setText(title);
    }

}
